<extend name="Public/base"/>

<block name="body">
  <!-- 标题 -->
  <div class="main-title">
    <h2>编辑文章</h2>
  </div>
  
  <form action="{:U('update')}" method="post" class="form-horizontal">
    <input type="hidden" value="{$data.uid}" name="uid"/>
    <div class="form-item cf">
      <label class="item-label">文章分类</label>
      <div class="controls" id="J_article_category">加载中...</div>
    </div>
    <div class="form-item">
      <label class="item-label">文章标题</label>
      <div class="controls">
        <input type="text" name="title" class="text input-large" value="{$data.title}">
      </div>
    </div>
    <div class="form-item">
      <label class="item-label">属性</label>
      <div class="controls">
        <label><input type="checkbox" name="is_topic" value="1"> 头条</label>
        <label><input type="checkbox" name="is_top" value="1"> 置顶</label>
      </div>
    </div>
    <div class="form-item">
      <label class="item-label">文章图片</label>
      <div class="controls">
        {:hook('uploadImages', array('name' => 'images', 'tpl' => 'one', 'value' => $data['images']))}
      </div>
    </div>
    <div class="form-item J_content {$data['cid'] == C('ARTICLE_JUMP_CID') ? ' hidden':''}">
      <label class="item-label">文章内容</label>
      <div class="controls">
        <textarea name="content">{$data.content}</textarea>
        {:hook('adminArticleEdit', array('name'=>'content', 'value'=>$data['content']))}
      </div>
    </div>
    <div class="form-item">
      <label class="item-label">文章描述</label>
      <div class="controls">
        <textarea name="description" class="textarea input-large" rows="4">{$data.description}</textarea>
      </div>
    </div>
    <div class="form-item J_link hidden">
      <label class="item-label">跳转地址</label>
      <div class="controls">
        <input type="text" name="to_url" class="text input-large" value="{$data.to_url}">
      </div>
    </div>
    <div class="form-item">
      <input type="hidden" name="id" value="{$data.id|default=''}">
      <button class="btn submit-btn ajax-post" id="submit" type="submit" target-form="form-horizontal">确 定</button>
      <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
    </div>
  </form>
</block>

<block name="script">
  <script src="__JS__/jquery/jquery.loadtype-2.0.js"></script>
  <script type="text/javascript">
    $(function(){
      /*导航高亮*/
      highlight_subnav('{:U("Article/index")}');
      $('#J_article_category').loadtype({
        type: 'ArticleCategory',
        name: 'cid',
        value: '{$data.cid}',
        callback: function(cid){
          if(cid == '{:C("ARTICLE_JUMP_CID")}'){
            $('.J_link').removeClass('hidden');
            $('.J_content').addClass('hidden');
          }else{
            $('.J_link').addClass('hidden');
            $('.J_content').removeClass('hidden');
          }
        }
      });
      Core.setValue('is_topic','{$data["is_topic"]}');
      Core.setValue('is_top','{$data["is_top"]}');
    });
  </script>
</block>
